<template>
  <div class="wrap">
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>数据统计</el-breadcrumb-item>
      <el-breadcrumb-item>数据报表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="box-card">
      <!--2、为ECharts准备一个具备大小（宽高）的Dom 注意：它必须要有固定宽高 -->
      <div id="main" style="width: 100%;height:400px;" />
    </el-card>
  </div>
</template>
<script>
import { getReportApi } from '../../api/add.js';
import * as echarts from 'echarts';
import _ from 'lodash';
export default {
  name: 'Report',
  components: { },
  data() {
    return {
    //   optionD: {}
    };
  },
  /* 此时，页面上的dom元素已经初始化完毕 */
  mounted() {
    this.getReport();
  },
  methods: {
    getReport() {
      getReportApi().then((res) => {
        const { data, meta } = res.data;
        if (meta.status !== 200) return this.$message.error(meta.msg);
        // 3、基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));
        // 4、准备数据和配置项
        const op = {
          title: {
            text: 'ECharts'
          },
          tooltip: {
            trigger: 'axis'
          }
        };
        var option = _.merge(data, op);
        // 5、展示数据
        myChart.setOption(option);
      });
    }
  }
};
</script>
<style scoped>
</style>
